package com.smarttest.portal.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.smarttest.common.beans.GeneralResultWithStatus;
import com.smarttest.portal.service.TestAutoBuildService;

@RequestMapping("/testAuto")
@Controller
public class TestAutoBuildController {

	@Autowired
	TestAutoBuildService testAutoBuildService;
	
	@RequestMapping(value = "/getAllGroups.action", method = {RequestMethod.GET,RequestMethod.POST})
	@ResponseBody
	public GeneralResultWithStatus getAllGroups() {
		return GeneralResultWithStatus.okData(null, testAutoBuildService.getAllGroups());
	}
	@RequestMapping(value = "/getService.action", method = {RequestMethod.GET,RequestMethod.POST})
	@ResponseBody
	public GeneralResultWithStatus getService(String group) {
		return GeneralResultWithStatus.okData(null, testAutoBuildService.getService(group));
	}
	@RequestMapping(value = "/getAllBuilds.action", method = {RequestMethod.GET,RequestMethod.POST})
	@ResponseBody
	public GeneralResultWithStatus getAllBuilds(String group, String service, String testenv, String time, String issuedstatus) {
		return GeneralResultWithStatus.okData(null, testAutoBuildService.getAllBuilds(group,service,testenv,time,issuedstatus));
	}
	@RequestMapping(value = "/updateManualReport.action", method = {RequestMethod.GET,RequestMethod.POST})
	@ResponseBody
	public GeneralResultWithStatus updateManualReport(int buildplatformId, int testresult, String casefile, String bugUrl) {
		return GeneralResultWithStatus.okData(null, testAutoBuildService.updateManualReport(buildplatformId,testresult,casefile,bugUrl));
	}
	@RequestMapping(value = "/getManualReport.action", method = {RequestMethod.GET,RequestMethod.POST})
	@ResponseBody
	public GeneralResultWithStatus getManualReport(int buildplatformId) {
		return GeneralResultWithStatus.okData(null, testAutoBuildService.getManualReport(buildplatformId));
	}
	@RequestMapping(value = "/rejectIssue.action", method = {RequestMethod.GET,RequestMethod.POST})
	@ResponseBody
	public GeneralResultWithStatus rejectIssue(int buildplatformId) {
		return GeneralResultWithStatus.okData(null, testAutoBuildService.rejectIssue(buildplatformId));
	}
	@RequestMapping(value = "/agreeIssue.action", method = {RequestMethod.GET,RequestMethod.POST})
	@ResponseBody
	public GeneralResultWithStatus agreeIssue(int buildplatformId) {
		return GeneralResultWithStatus.okData(null, testAutoBuildService.agreeIssue(buildplatformId));
	}
}
